package service.impl;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import pojo.Orders;
import service.OrdersManager;

public class OrdersManagerImpl implements OrdersManager {

	@Override
	public int addOrders(Orders o,Connection con) {
		String sql="insert into orders (uname,bname,buydate) values(?,?,?)";
		int m=0;
		try {
			PreparedStatement pst=con.prepareStatement(sql);
			pst.setString(1, o.getuName());
			pst.setString(2, o.getbName());
			pst.setDate(3, new Date(o.getBuyDate().getTime()));
			m=pst.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return m;
	}

}
